package cn.iocoder.yudao.module.crossborder.order.api.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * 订单创建请求 DTO
 *
 * @author LHL
 */
@Schema(description = "RPC 服务 - 订单创建请求 DTO")
@Data
public class OrderCreateReqDTO {

    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
    @NotNull(message = "用户编号不能为空")
    private Long userId;

    @Schema(description = "订单类型", example = "1")
    private Integer orderType;

    @Schema(description = "订单来源", example = "1")
    private Integer orderSource;

    @Schema(description = "货币类型", example = "USD")
    private String currency;

    @Schema(description = "汇率", example = "6.8")
    private BigDecimal exchangeRate;

    @Schema(description = "收货人姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    @NotEmpty(message = "收货人姓名不能为空")
    private String receiverName;

    @Schema(description = "收货人电话", requiredMode = Schema.RequiredMode.REQUIRED, example = "13800138000")
    @NotEmpty(message = "收货人电话不能为空")
    private String receiverPhone;

    @Schema(description = "收货地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "上海市浦东新区张江高科技园区")
    @NotEmpty(message = "收货地址不能为空")
    private String receiverAddress;

    @Schema(description = "收货邮编", example = "200000")
    private String receiverZipCode;

    @Schema(description = "收货国家", example = "中国")
    private String receiverCountry;

    @Schema(description = "备注", example = "请尽快发货")
    private String remark;

    @Schema(description = "订单项列表", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "订单项不能为空")
    @Valid
    private List<OrderItemCreateReqDTO> items;

    /**
     * 订单项创建请求 DTO
     */
    @Schema(description = "订单项创建请求")
    @Data
    public static class OrderItemCreateReqDTO {

        @Schema(description = "商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3072")
        @NotNull(message = "商品编号不能为空")
        private Long productId;

        @Schema(description = "商品SKU编号", example = "4096")
        private Long skuId;

        @Schema(description = "购买数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
        @NotNull(message = "购买数量不能为空")
        private Integer quantity;

        @Schema(description = "备注", example = "用户备注信息")
        private String remark;

    }

}
